﻿@using A2.ERP.Models
@{
    List<t_BuyReceipt> receipt = ViewBag.Payreceipt;
    t_BuyReceipt Payreceipt=ViewBag.Pay;
}
<section id="ModuleBuyPay">
    <style type="text/css">
        input { margin-right: 100px; }
            input.long { width: 520px; }
        .label { margin: 0px; }
        #CROrder {display:none }
    </style>
     <div id="CROrder">
     <div class="card-header">采 购 入 库 订 单</div>
        <div class="card-body">
            <div class="form-group">
                从<input type="date" class="label"/>到<input type="date" class="label"/> <input type="button" value="查询" />
                <table class="table">
                    <thead>
                        <tr>
                            <th>操作</th>
                             <th>订单号</th>
                             <th>日期</th>
                             <th>库房</th>
                             <th>库区</th>
                             <th>入库日期</th>
                             <th>合计金额</th>
                             <th>状态</th>
                        </tr>
                    </thead>
                    <tbody>
                        @if (receipt != null)
                        {
                            foreach (var item in receipt)
                            {
                                <tr>
                                     <td onclick="ChangeID('@item.ReceiptOrderID')"><input type="button"  value="选择" class="btn btn-success" /></td>
                                     <td>@item.ReceiptOrderID</td>
                                     <td>@item.ReceiptOrderDate</td>
                                     <td>@item.StoreHouseID</td>
                                     <td>@item.HouseDetailID</td>
                                     <td>@item.TradeDate</td>
                                     <td>@item.TotalPrice</td>
                                     <td>@item.State</td>
                               </tr>
                            }
                        }
                        
                    </tbody>
                </table>
                </div>
            </div>
    </div>
    @using (Html.BeginForm("ModuleBuyPay", "Purchase", FormMethod.Post, new
            {
                @class = "form addBuyPay"
            }))
    {
        
            <div class="card-header">采 购 付 款</div>
        <div class="card-body">
            <div class="form-group">
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">采购单号</span>
                    </div>
                    <input type="text" name="BuyReceiptID" value="@(Payreceipt == null ? "" : Payreceipt.ReceiptOrderID)" class="label">
                    <input type="button" value="引用" id="ShowCR"/>
                    <div class="input-group-prepend">
                        <span class="input-group-text">制单日期</span>
                    </div>
                    <input type="date" name="CreateDate" value="@(Payreceipt == null ? "" : Payreceipt.ReceiptOrderDate)">

                    <div class="input-group-prepend">
                        <span class="input-group-text">票号</span>
                    </div>
                    <input type="text" value="无">
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">单据总额</span>
                    </div>
                    <input type="number" name="RealPay" class="number" value="@(Payreceipt == null ? 0 : Payreceipt.TotalPrice)">
                    <div class="input-group-prepend">
                        <span class="input-group-text">已付总额</span>
                    </div>
                    <input type="number" name="AttachPay" class="number" value="0.00">

                    <div class="input-group-prepend">
                        <span class="input-group-text">支付类型</span>
                    </div>
                    <input type="text" name="PayType" value="@(Payreceipt == null ? "" : "银行付款")">
                </div>
                 <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">本次实付</span>
                    </div>
                    <input type="number" name="RealPay" class="number" value="0.00">
                    <div class="input-group-prepend">
                        <span class="input-group-text">附加金额</span>
                    </div>
                    <input type="number" name="AttachPay" class="number label" value="0.00" >
                    <label>(由于各种因素所花的费用，不用于计算)</label>
                </div>
                <div class="input-group mb-3">
                    <div class="input-group-prepend">
                        <span class="input-group-text">备注</span>
                    </div>
                    <input type="text" name="Description" value="@(Payreceipt == null ? "" : Payreceipt.Description)" class="long">
                    <input type="submit" value="提交" class="btn btn-primary"/>
                </div>
            </div>
        </div>

    }
   



</section>
<script type="text/javascript">
    ;
    !function () {
        $addBuyPayFrm = $("#ModuleBuyPay .addBuyPay");
        $addBuyPayFrm.submit(function (e) {
            e.preventDefault();
            $addBuyPayFrm.ajaxSubmit({
                type: 'POST',
                dataType: 'json',
                success: function (e) {
                    alert('添加成功');
                    $tab.reloadTab('#ModuleBuyPay');
                }
            });
        });
        $ShowCRFrm=$("#ShowCR");
        $ShowCRFrm.on('click',function(){
            $("#CROrder").css("display","block");
        })
    }();

    function ChangeID(id) {
        $("#CROrder").css("display","none");
        $tab.reloadTab('#ModuleBuyPay', [{ id: id }]);
    }
</script>
